Write a program of hollow square pattern in python - Hollow Square Pattern program in python - Python Programs - Pattern programs in python

Hollow Square Pattern



Output

*****

*      *

*      *

*      *

*****

Python Code:

# hollow square pattern

n = 5

for i in range(n):

    for j in range(n):

        if i == 0 or i == n - 1 or j == 0 or j == n - 1:

            print('*', end='')

        else:

            print(' ', end='')

    print('')

Here is the Practical of the above program in Jupyter Notebook



Comments